package demo;

import java.util.Scanner;

public class Demo3 {
    private static Object locker1=new Object();
    public static void main(String[] args) throws InterruptedException {
        Thread t1=new Thread(()->{
            Scanner scanner=new Scanner(System.in);
            while (true){
                synchronized(locker1){
                    int a=scanner.nextInt();
                    System.out.println(a);
                }
            }
        });
        t1.start();
        Thread.sleep(1000);
        Thread t2=new Thread(()->{
            synchronized (locker1){
                System.out.println("hello");
            }
        });
        t2.start();
    }
}
